using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace MvcExtExample.Handlers
{
    public partial class CheckCode : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request.QueryString["code"]))
            {
                string myCode = Request.QueryString["code"].ToString().Trim().ToLower();//统一为小写
                #region 用Session
                if (Session["ck"] != null && Session["ck"].ToString().Trim() != "")
                {
                    if (myCode == Session["ck"].ToString().ToLower())
                    {
                        Response.Write("t");//正确
                    }
                    else
                    {
                        Response.Write("f");//错误
                    }
                }
                else
                {
                    Response.Write("null");//空值，提示重刷验证码
                }
                #endregion
                #region 用Cookie
                //if (Request.Cookies["CheckCode"] != null)
                //{
                //    HttpCookie cookies = Request.Cookies["CheckCode"];
                //    if (myCode == cookies.Values["checkCode"].ToString())
                //    {
                //        Response.Write("t");//正确
                //    }
                //    else
                //    {
                //        Response.Write("f");//错误
                //    }
                //}
                //else
                //{
                //    Response.Write("null");//空值，提示重刷验证码
                //}
                #endregion
            }
            else
            {
                Response.Write("f");
            }

        }
    }
}